// pages/tech/fruit-check/detail/detail.js
//调用方式 /pages/tech/fruit-check/detail/detail?appid=12&recordid=dcee
var httpUtil = require('../../../../utils/httpUtil.js')
var uiUtil = require('../../../../utils/uiUtil.js')
var emptyUtil = require('../../../templates/empty/empty.js')
const app = getApp()
var that

Page({

  /**
   * 页面的初始数据
   */
  data: {
    appId: null,
    recordId: null,
    data: null,

    emptyParam: {
      emptyStatus: 0
    },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    that = this;
    uiUtil.showLoading("正在加载..")
    var appId = options.appid
    var recordId = options.recordid
    if (!appId || !recordId) { //-退出
      wx.navigateBack({})
      return;
    }

    this.setData({
      appId: appId,
      recordId: recordId
    })

    this.requestData()
  },


  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {
    return util.handleShareApp()
  },

  /**
   * 获取数据
   */
  requestData() {
    httpUtil.PostRequestHeaderApp("detail_fruit_check", {
      appId: that.data.appId,
      recordId: that.data.recordId}, {
      success(res) {
        that.setData({
          data: res
        })
      },
      fail(code, res) {
        var text = emptyUtil.getErrText(code, res, "获取信息失败")
        emptyUtil.showFailView(text)
      },
      complete() {
        uiUtil.hideLoading()
      }
    })
  },

  /**
   * 提交反馈点击
   */
  onFeedbackBtnClick(e) {
    var appId = that.data.appId
    var recordId = that.data.recordId
    var satisfaction = that.data.data.satisfaction
    wx.navigateTo({
      url: '/pages/tech/feedback/feedback?appid=' + appId + '&recordid=' + recordId + '&satisfaction=' + encodeURIComponent(JSON.stringify(satisfaction)) + '&requestname=comment_fruit_check'
    })
  },
  /**
  * 地图点击
  */
  onMapClick(e) {
    var lng = this.data.data.signLongitude
    var lat = this.data.data.signLatitude

    wx.navigateTo({
      url: '/pages/tech/map/map?lng=' + lng + '&lat=' + lat,
    })
  }
})